﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BoolanSlide.ElementMenu;
using BoolanSlide.RedoUndo;
using BoolanSlide.UIElement.Shapes.TextShapes.Common;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;

namespace BoolanElement
{
    public abstract class BooLineBase:BooUIBase
    {
        public abstract BooLineBaseElement BooLineBaseElement
        {
            get;
        }


        public BooLineBase(BooLineBaseElement BooLineBaseElement)
        {
            BooLineBaseElement.ShapePropertyChanged += BooLineBaseElement_ShapePropertyChanged;
        }

        public virtual void BooLineBaseElement_ShapePropertyChanged(object sender, BoolanSlide.UIElement.Shapes.TextShapes.Common.ShapePropertyChangedArgs args)
        {
            if(args.PropertyName=="Shape")
                ApplyShapeChange();
            else if (args.PropertyName == "Style")
            {
                ApplyStyleChange();
            }
            else if (args.PropertyName == "UpdateUI")
            {
                LoadFromElement(args.Data as BooLineBaseElement);
            }
        }

        public abstract Point GetMenuDisplayPosition();

        public virtual void LoadFromElement(BooElement booElement)
        {
            (Element as BooLineBaseElement).Load(booElement as BooLineBaseElement);
        }

        public abstract void ApplyShapeChange();
        public abstract void ApplyStyleChange();

        protected override void BooUIBase_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            base.BooUIBase_ManipulationCompleted(sender, e);
            RedoUndoHelper.SaveStatus(this);
        }

        public override void UpdateUI(BooElement booElement)
        {
            (Element as BooLineBaseElement).UpdateUI(booElement.Clone());
        }

        public override BooElement Element
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override MenuBase UIMenu
        {
            get { throw new NotImplementedException(); }
        }

        public override bool CanHandledAcceleratorBySelf()
        {
            return false;
        }
    }
}
